home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1996 #15 / Monster Media Number 15 (Monster Media)(July 1996).ISO / os2 / srefv112.zip / SREFPRC1.ZIP / FIX_URL.SRF < prev    next >
Text File  |  1996-05-13  |  2KB  |  76 lines

  1. /* ----------------------------------------------------------------------- */
  2. /* FIX_URL: Make a fully specified http://url out of message            */
  3. /* mayl not work if subdirectories have periods */
  4. /* ----------------------------------------------------------------------- */
  5.  
  6. sref_fix_url:
  7. parse arg message,servername,serverport
  8.  
  9. /* use defaults if not provided */
  10. if servername="" then
  11.   servername=servername()
  12. if serverport="" then
  13.   serverport=extract(serverport)
  14.  
  15.  
  16.  message=strip(translate(message,'/','\'))
  17.  
  18.  if abbrev(translate(message),"HTTP://")=1 then
  19.              return message              /* assume the rest is legit */
  20.  
  21. /* if not a fully qualified http url (i.e. http://xxx.yyy/zzz) then
  22.    make it so
  23.  
  24. Rule: (assuming  no http:// in message)
  25.   Strip leading any leading /
  26.   Look for a /  If no slash found, 
  27.         look for periods.  If > 1 found, it's a "default" for a ip address
  28.         if <2 found, it's a local file
  29.   Check stuff before first /.
  30.          If it has any periods, its an ip address (stuff after is the url)
  31.          If no periods, it's a local url (stuff before is first subdirectory)
  32. */
  33.  
  34. message=strip(message,'l','/')
  35.  
  36.  
  37. islash=pos('/',message)
  38. if islash=0 then do
  39.     foo=translate(message,' ','.')
  40.     if words(foo)>2 then do
  41.           anip=message
  42.           aport=80
  43.           afile=""
  44.     end
  45.     else do
  46.           anip=servername
  47.           aport=serverport
  48.           afile=message
  49.     end
  50. end                                     /* no slashes found */
  51.  
  52. else do
  53.    parse var message p1 '/' p2     /* slash found,extract what's before it */
  54.    foo=translate(p1,' ','.')
  55.    if words(foo)>1 then do    /* >0 periods signifies this is an ip address */
  56.           anip=p1
  57.           aport=80
  58.           afile=p2
  59.     end
  60.     else do
  61.           anip=servername
  62.           aport=serverport
  63.           afile=message
  64.     end
  65. end
  66.  
  67. isit="http://"||anip
  68. if aport<>80 then
  69.     isit=isit||':'||aport
  70. isit=isit||'/'||afile
  71.  
  72.  return isit
  73.  
  74.  
  75.  
  76.